<template>
  <el-dialog title="pdf预览" v-model="visible" width="1200px" :close-on-click-modal="false">
     <div id="pdf"></div>

  </el-dialog>
</template>

<script lang="ts" setup>
import PDFObject from 'pdfobject'
import { ref, nextTick } from 'vue'
const visible = ref(false)
const baseUrl = import.meta.env.DEV ? '/proxy' : import.meta.env.VITE_APP_API_BASEURL

const open = async (pdfUrl: string) => {
  visible.value = true
  await nextTick()
  PDFObject.embed(baseUrl + pdfUrl, '#pdf', { width: '100%',height: '100%' })

}
defineExpose({ open })
</script>

<style lang="scss" scoped>
.pdfobject-container {
    height: 680px;
    border: 1rem solid rgba(0, 0, 0, 0.1);
}

::v-deep .pdfClass img{
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
}

</style>
